package com.burgeon.backend.SHOPBACKEND.controller;

import com.burgeon.backend.SHOPBACKEND.entity.Activity;
import com.burgeon.backend.SHOPBACKEND.entity.SevenDaysReturn;
import com.burgeon.backend.SHOPBACKEND.entity.mailActivity.Gabalnara;
import com.burgeon.backend.SHOPBACKEND.service.BackendActivityService;
import com.burgeon.backend.stsutil.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;

@RequestMapping("shopbackent/activity")
@RestController
@CrossOrigin
public class BackendActivityController extends BaseController {

    @Autowired
    private BackendActivityService backendActivityService;

    @RequestMapping("sevenDaysReturnSet")
    public ResponseResult<Void> sevenDaysReturnSet(String type,String state,String account) {
        backendActivityService.sevenDaysReturnSet(type,state,account);
        return new ResponseResult<>(SUCCESS);
    }

    @RequestMapping("sevenDaysReturnData")
    public ResponseResult<SevenDaysReturn> sevenDaysReturnData(String account) {
        SevenDaysReturn data = backendActivityService.sevenDaysReturnData(account);
        return new ResponseResult<SevenDaysReturn>(SUCCESS,data);
    }

    @RequestMapping("getExemptionFromPostage")
    public ResponseResult<Gabalnara> getExemptionFromPostage(String account) {

        Gabalnara data = backendActivityService.getExemptionFromPostage(account);
        return new ResponseResult<Gabalnara>(SUCCESS,data);
    }

    @RequestMapping("exemptionFromPostage")
    public ResponseResult<Void> exemptionFromPostage(String price,String isUse,String account) {

        backendActivityService.exemptionFromPostage(price,isUse,account);
        return new ResponseResult<>(SUCCESS);
    }


    @RequestMapping("data")
    public ResponseResult<List<Activity>> getData(String account) {
        List<Activity> data = backendActivityService.getData(account);
        return new ResponseResult<List<Activity>>(SUCCESS,data);
    }

    @RequestMapping("create")
    public ResponseResult<Void> createData(Activity activity,String account) {
        activity.setToken(account);
        backendActivityService.addData(activity);
        return new ResponseResult<>(SUCCESS);
    }

    @RequestMapping("up")
    public ResponseResult<Void> upData(Activity activity,String account) {
        activity.setToken(account);
        backendActivityService.upData(activity);
        return new ResponseResult<>(SUCCESS);
    }

    @RequestMapping("del")
    public ResponseResult<Void> delData(String id) {
        backendActivityService.delData(id);
        return new ResponseResult<>(SUCCESS);
    }

}
